package com.baitiaojun.api.domain.user;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Email;
import javax.validation.constraints.Pattern;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("用户系统信息")
public class User {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(readOnly = true)
    private Long id;

    @Pattern(regexp = "^1(3[0-9]|5[0-3,5-9]|7[1-3,5-8]|8[0-9])\\d{8}$", message = "手机号码格式错误")
    @ApiModelProperty(value = "手机号用户登录的手机账号", required = true)
    private String phone;

    @Email(message = "邮箱格式不正确")
    @ApiModelProperty("用户邮箱")
    private String email;

    @ApiModelProperty(value = "用户登录的密码", required = true)
    private String password;

    @ApiModelProperty(readOnly = true)
    private String salt;

    @ApiModelProperty(readOnly = true)
    private Date createtime;

    @ApiModelProperty(readOnly = true)
    private Date updatetime;

    @ApiModelProperty(hidden = true)
    private UserInfo userInfo;
}